package net.sshiffon.logging;

import org.apache.log4j.Logger;
public class GroovySanitizingLogger {
	Logger logger;
	List<String> methodsToCheck= ['warn','error'];
	public GroovySanitizingLogger(Logger logger)
	{
		ExpandoMetaClass mc = new ExpandoMetaClass(GroovySanitizingLogger, false, true)
		mc.initialize()
		this.metaClass = mc
		this.logger = logger
	}
	def methodMissing(String name, args) {
		if (name in methodsToCheck) {
			if (args.length>1 && args[1] instanceof Throwable) 
			{
				args[1]= org.codehaus.groovy.runtime.StackTraceUtils.deepSanitize(args[1])
			}
		}
		logger."$name"(*args)
	}
}
